package com.cqeec.service.imp;

import java.sql.Connection;

import javax.swing.JOptionPane;

import com.cqeec.dao.CallRollDao;
import com.cqeec.dao.imp.CallRollDaoImpl;
import com.cqeec.domain.Ieaved;
import com.cqeec.domain.Student;
import com.cqeec.service.CallRollService;

public class CallRollServiceImpl implements CallRollService {

	@Override
	public int updateCallRollByStudentName(Connection conn, Student student, String courseNum) {
		CallRollDao dao = new CallRollDaoImpl();
		
		int status;
		try {
			status = dao.findCallRollByStudentName(conn,student,courseNum);
			if(status!= 0) {
				status = dao.updateCallRollByStudentName( conn,student,courseNum);
			}else {
				status = dao.persistCallRoll(conn,student,courseNum);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return 0;
	}


/**
 * 请假处理
 */
	@Override
	public void call_rolls(Connection con, Ieaved ieaved) {
		CallRollDao callRollDao=new CallRollDaoImpl();
		int rs= callRollDao.callroll(con,ieaved);
		if(rs!=0) {
			JOptionPane.showMessageDialog(null, "请假成功，等待老师回信");
		}
		else
			JOptionPane.showMessageDialog(null, "请假失败");
			
		
	}

}
